<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl.linkpage.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/common.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/My97DatePicker/WdatePicker.js"></script>

<div class="tongrong-box" style="width:650px;">
	<form class="login-box-form J-ajaxForm" action="<?php echo $this->id > 0 ? '/bank/rtedit/option/save/' : '/bank/rtsave/option/save/';?>" method="post" autocomplete="off">
	<div class="tongrong-box-main">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0">
        	<tr>
            	<td width="100px" height="35">银       行：</td>
                <td colspan="3">
                	<select name="rt_bank_id">
                    	<option>请选择</option>
                        <?php if(!empty($this->bank)) foreach($this->bank as $key => $val){?>
                        <option <?php echo $val['bk_id'] == $this->data['rt_bank_id'] ? 'selected' :'';?> value="<?php echo $val['bk_id'];?>"><?php echo $val['bk_name'];?></option>
                        <?php
						}
						?>
                    </select>
                </td>
            </tr>
            <tr>
            	<td height="35">产品类型：</td>
                <td>
                	<select name="rt_type">
                    	<option <?php echo $this->data['rt_type'] == '信用卡分期(利息分期)' ? 'selected' :''?> value="信用卡分期(利息分期)">信用卡分期(利息分期)</option>
                        <option <?php echo $this->data['rt_type'] == '信用卡分期(利息一次性)' ? 'selected' :''?> value="信用卡分期(利息一次性)">信用卡分期(利息一次性)</option>
						<option <?php echo $this->data['rt_type'] == '抽奖' ? 'selected' :''?> value="抽奖">抽奖</option>
                    </select>
                </td>
                <td height="35">年 限（月）：</td>
                <td>
                	<select name="rt_ylimit">
                    	<option <?php echo $this->data['rt_ylimit'] == '12' ? 'selected' :'';?> value="12">12</option>
                        <option <?php echo $this->data['rt_ylimit'] == '24' ? 'selected' :'';?> value="24">24</option>
                        <option <?php echo $this->data['rt_ylimit'] == '36' ? 'selected' :'';?> value="36">36</option>
                    </select>
                </td>
            </tr>
            <tr>
            	<td height="35">省内新车代码：</td>
                <td>
                	<input name="rt_newcode_in" type="text" id="rt_newcode_in" size="35" value="<?php echo $this->data['rt_newcode_in'];?>" />
                </td>
                <td height="35">利率：</td>
                <td>
                	<input name="rt_newrate_in" type="text" id="rt_newrate_in" size="35" value="<?php echo $this->data['rt_newrate_in'];?>" />
                </td>
            </tr>

            <tr>
            	<td height="35">省内二手车代码：</td>
                <td>
                	<input name="rt_seccode_in" type="text" id="rt_seccode_in" size="35" value="<?php echo $this->data['rt_seccode_in'];?>" />
                </td>
                <td height="35">利率：</td>
                <td>
                	<input name="rt_secrate_in" type="text" id="rt_secrate_in" size="35" value="<?php echo $this->data['rt_secrate_in'];?>" />
                </td>
            </tr>
            
            <tr>
            	<td height="35">省外新车代码：</td>
                <td>
                	<input name="rt_newcode_out" type="text" id="rt_newcode_out" size="35" value="<?php echo $this->data['rt_newcode_out'];?>" />
                </td>
                <td height="35">利率：</td>
                <td>
                	<input name="rt_newrate_out" type="text" id="rt_newrate_out" size="35" value="<?php echo $this->data['rt_newrate_out'];?>" />
                </td>
            </tr>

            <tr>
            	<td height="35">省外二手车代码：</td>
                <td>
                	<input name="rt_seccode_out" type="text" id="rt_seccode_out" size="35" value="<?php echo $this->data['rt_seccode_out'];?>" />
                </td>
                <td height="35">利率：</td>
                <td>
                	<input name="rt_secrate_out" type="text" id="rt_secrate_out" size="35" value="<?php echo $this->data['rt_secrate_out'];?>" />
                </td>
            </tr>
			<!--
            <tr>
            	<td height="35">新车贷款上限：</td>
                <td>
                	<input name="rt_newloan_limit" type="text" id="rt_newloan_limit" size="35" value="<?php echo $this->data['rt_newloan_limit'];?>" /> %
                </td>
                <td height="35">二手车贷款上限：</td>
                <td>
                	<input name="rt_secloan_limit" type="text" id="rt_secloan_limit" size="35" value="<?php echo $this->data['rt_secloan_limit'];?>" /> %
                </td>
            </tr>
            -->
            <tr>
            	<td height="35">启用时间：</td>
                <td>
                	<input name="rt_up_time" type="text" id="rt_up_time" onClick="WdatePicker()" size="35" value="<?php echo $this->data['rt_up_time'];?>" />
                </td>
            </tr>
            
        </table>
    </div>
    <div class="luru-box-btn mt30" style="margin-right:30px;">
		<input type="hidden" name="option" value="save" />
		<input type="hidden" name="id" value="<?php echo $this->id;?>" />
    	<input class="btn-submit-blue fn-left mr15 J-submit" type="submit" value="提交" />
        <a class="a-btn-close J-a-btn-close" href="javascript:;">关闭</a>
    </div>
	</form>
</div>

<script>
	$("#areas").Linkage({ url:"/public/ajax/?option=city",selected:['<?php echo empty($this->data['br_province']) ? '浙江省' : $this->data['br_province'];?>','<?php echo empty($this->data['br_city']) ? '杭州市' : $this->data['br_city'];?>',''],callback:function(data){
		var text = new Array();
		var value = new Array();
		for(i in data[0]){
		  if(data[0][i]!=0){
			text.push(data[1][i]);
			value.push(data[0][i]);
		  }
		}
		$("#test").val(value.join(','));
		FireEvent(document.getElementById("test"),"change");
	}});
	
	//关闭弹出
	$(".J-a-btn-close").on('click',function(){
		var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
		parent.Ext.getCmp(winElement.id).close();
		
	});
	
	$(document).ready(function(e) {
        $(".J-submit").on('click',function(){
			$(this).dyhlForm({
				beforefunction:submitChk,
				nofunction:function(){
					$(".J-submit").prop('disabled',false);
				},
				sucessfunction:function(data){
					$(".J-submit").prop('disabled',false);
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							window.parent.App.store.reload();
							var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
							parent.Ext.getCmp(winElement.id).close();
						});
					}else{
						Ext.Msg.alert('提示',data['msg']);
					}
				}	
			});	
		});
    });
	
	//表单验证
	function submitChk(){
		if($("#rt_newcode_in").val() == ''){
			Ext.Msg.alert('提示','省内新车代码不能为空!');	
			return false;
		}
		
		if($("#rt_newrate_in").val() == ''){
			Ext.Msg.alert('提示','省内新车代码利率不能为空!');	
			return false;
		}
		
		if($("#rt_seccode_in").val() == ''){
			Ext.Msg.alert('提示','省内二手车代码不能为空!');	
			return false;
		}
		
		if($("#rt_secrate_in").val() == ''){
			Ext.Msg.alert('提示','省内二手车代码利率不能为空!');	
			return false;
		}
		
		if($("#rt_newcode_out").val() == ''){
			Ext.Msg.alert('提示','省外新车代码不能为空!');	
			return false;
		}
		
		if($("#rt_newrate_out").val() == ''){
			Ext.Msg.alert('提示','省外新车代码利率不能为空!');	
			return false;
		}
		
		if($("#rt_seccode_out").val() == ''){
			Ext.Msg.alert('提示','省外二手车代码不能为空!');	
			return false;
		}
		
		if($("#rt_secrate_out").val() == ''){
			Ext.Msg.alert('提示','省外二手车代码率不能为空!');	
			return false;
		}
		$(".J-submit").prop('disabled',true);
			
	}
	
</script>

<?php include $this->Render('footer.php'); ?>